package com.xh.xyzp.controller;

import com.xh.xyzp.common.domain.vo.resp.ApiResult;
import com.xh.xyzp.common.domain.vo.resp.PageResp;
import com.xh.xyzp.domain.entity.Company;
import com.xh.xyzp.domain.vo.CompanyPageReq;
import com.xh.xyzp.domain.vo.CompanySubmitReq;
import com.xh.xyzp.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "公司接口")
@RestController
@RequestMapping("/company")
public class CompanyController {

    @Autowired
    private CompanyService companyService;

    @ApiOperation("详细信息")
    @PostMapping("/info/{companyId}")
    public ApiResult<Company> getInfo(@PathVariable("companyId") Long companyId) {
        return ApiResult.success(companyService.getInfo(companyId));
    }

    @ApiOperation("新增/编辑")
    @PostMapping("/submit")
    public ApiResult<Void> submit(@RequestBody CompanySubmitReq req) {
        companyService.submit(req);
        return ApiResult.success();
    }

    @ApiOperation("列表")
    @PostMapping("/list")
    public ApiResult<PageResp<Company>> getList(@RequestBody CompanyPageReq req) {
        return ApiResult.success(companyService.getList(req));
    }

    @ApiOperation("删除")
    @PutMapping("/delete/{companyId}")
    public ApiResult<Void> delete(@PathVariable Long companyId) {
        companyService.delete(companyId);
        return ApiResult.success();
    }

} 